<template>
	<view class="news">
		<news-list @itemClick='goDetail' :list="newsList"></news-list>
	</view>
</template>

<script>
	import newsList from '@/components/news-list/news-list.vue'
	export default {
		data() {
			return {
				newsList: []
			}
		},
		components: {
			newsList
		},
		methods: {
			async getNews() {
				const res = await this.$myRequest({
					url: '/api/getnewslist/'
				})
				this.newsList = res.data.message
			},
			goDetail(id){
				uni.navigateTo({
					url:'/pages/news-details/news-details?id='+id
				})
			}
		},
		onLoad() {
			this.getNews()
		}
	}
</script>

<style lang="scss">
	.news {
		.news-item {
			display: flex;
			padding: 10rpx 20rpx;
			border-bottom: 1px solid #CCCCCC;

			image {
				width: 200rpx;
				height: 150rpx;
				min-width: 200rpx;
				max-width: 200rpx;
			}

			.right {
				margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.title {
					font-size: 30rpx;
				}

				.info {
					font-size: 24rpx;

					text:nth-child(2) {
						margin-left: 30rpx;
					}
				}
			}
		}
	}
</style>
